﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WindowsFormsApplication2.CLASS;
using WindowsFormsApplication2.FORMS;

namespace WindowsFormsApplication2
{
    public partial class frmRegXT : Form
    {
       //string a, b, c, d;
        string _Id;
         public enum clicktype
        {
            Add = 1,
            Edit = 2,

        }

        clicktype ConsructorType = new clicktype();

        public frmRegXT()
        {
            InitializeComponent();
            ConsructorType = clicktype.Add;
            
        }
         public frmRegXT(XT _xt)
        {
            ConsructorType = clicktype.Edit;
            InitializeComponent();
             _Id = _xt.XTolologchId ;
            xtner.Text = _xt.XTolologchName;
            uname.Text = _xt.XTolologchUName;
            xtaddress.Text = _xt.XTolologchAddress;
            xtphone.Text = _xt.XTolologchPhone;
            xtpass.Text = _xt.XTolologchPass;
        }
        private void button2_Click(object sender, EventArgs e)
        {
            frmXT frm = new frmXT();
            frm.dataGridViewXT.DataSource = DBTools.selecQryTmp("Select *from XTolologch");
            this.Close();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (ConsructorType == clicktype.Add)
            {
                XT.AddFunction(_Id, xtner.Text, uname.Text, xtaddress.Text, xtphone.Text, xtpass.Text);
                MessageBox.Show("Нэмэх үйлдэл");
                frmXT frm = new frmXT();
                frm.dataGridViewXT.DataSource = DBTools.selecQryTmp("Select *from XTolologch");
            }
            else
            {

                XT.EditFunction(_Id, xtner.Text, uname.Text, xtaddress.Text, xtphone.Text, xtpass.Text);
                MessageBox.Show("Засах үйлдэл");

            }
           
        }

       
    }
}
